﻿using System;

enum Gender {Male, Female}

class InvalidStudentException : ApplicationException 
{
    public InvalidStudentException()
        : base()
    {
    }

    public InvalidStudentException(string message)
        : base(message)
    {
    }

    public InvalidStudentException(string message, Exception innerException)
        : base(message, innerException)
    {
    }
}



class Studnet
{
    private int age;
    private Gender gender;
    private string name;
    private int grade;
    private long ssn;
    private DateTime birthDate;

    private DateTime minDate = new DateTime(1900, 1, 1);
    private DateTime maxDate = new DateTime(2010, 1, 1);

    public int GetAge()
    {
        return this.age;
    }
    public Gender GetGender()
    {
        return this.gender;
    }
    public string GetName()
    {
        return this.name;
    }
    public int GetGrade()
    {
        return this.grade;
    }
    
    public Studnet(int age, Gender gender, string name, int grade)
        : this(age, gender, name, grade, 100000000, new DateTime(1990,1,1))
    {
    }

    public Studnet(int age, Gender gender, string name, int grade, long ssn, DateTime birthDate)
    {
        if (age < 7 || age > 18)
            throw new InvalidStudentException("The student age should be in the interval [7...18].");

        if (name.Length < 10 || name.Length > 50)
            throw new InvalidStudentException("The student name should be between 10 and 50 characters long.");

        if (grade < 1 || grade > 12)
            throw new InvalidStudentException("The student grade should be in the interval [1...12].");

        if (ssn < 100000000 || ssn > 999999999)
            throw new InvalidStudentException("The student ssn should be 9 digits long.");

        if (birthDate < minDate || birthDate > maxDate)
            throw new InvalidStudentException("The student should be born in the interval " + minDate + " and " + maxDate + ".");

        this.age = age;
        this.gender = gender;
        this.name = name;
        this.grade = grade;
        this.ssn = ssn;
        this.birthDate = birthDate;

    }

    public override string ToString()
    {
        return name + ", " + age + ", " + gender + ", " + grade + " grade,\n" +
            "ssn: " + ssn + "\n" +
            "born on: " + birthDate.Year + "." + birthDate.Month + "." + birthDate.Day;

    }
}


class ExceptionHandling
{
    static void Main(string[] args)
    {
        try
        {
            Studnet st1 = new Studnet(15, Gender.Female, "Nadejda Govejda", 8, 435899345, new DateTime(1990,4,24));
            Console.WriteLine(st1);
        }
        catch (ArgumentOutOfRangeException e)
        {
            Console.WriteLine(e);
        }
    }
}
